<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
</head>
<body>
	<form action="${pageContext.request.contextPath }/list" method="post" id="fm">
	<input type="hidden" name="pageNum" value="${info.pageNum }" id="ym">
		报销日期<input type="text" name="reimburseDate" value="<fmt:formatDate value="${rm.reimburseDate }" pattern="yyyy-MM-dd"/>">至<input type="text" name="endreimburseDate" value="<fmt:formatDate value="${rm.endreimburseDate }" pattern="yyyy-MM-dd"/>">
		报销单号<input type="text" name="reimburseId" value="${rm.reimburseId }">
		<br>
		医疗总费用<input type="text" name="totalFee" value="${rm.totalFee }">至<input type="text" name="endtotalFee" value="${rm.endtotalFee }">
		所属部门
			<select name="deptId" id="dep" data-dep="${ri.deptId }">
				<option value="">请选择</option>
			</select>
		员工姓名<input type="text" name="empName" value="${rm.empName }">
		员工编号<input type="text" name="empId" value="${rm.empId }">
		<input type="submit" value="查询">
	</form>
	<a href="${pageContext.request.contextPath }/update">添加</a>
	<table>
		<tr>
			<td>报销日期</td>
			<td>报销单号</td>
			<td>员工编号</td>
			<td>员工姓名</td>
			<td>性别</td>
			<td>所属部门</td>
			<td>医疗总费用</td>
			<td>附件</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${info.list }" var="li">
			<tr>
				<td>${li.reimburseId }</td>
				<td>
					<fmt:formatDate value="${li.reimburseDate }" pattern="yyyy-MM-dd"/>
				</td>
				<td>${li.empId }</td>
				<td>${li.empName }</td>
				<td>${li.sex.value }</td>
				<td>${li.dname }</td>
				<td>${li.totalFee }</td>
				<td>${li.attachment }</td>
				<td><a href="${pageContext.request.contextPath }/update?id=${li.reimburseId }">修改</a><a href="javascript:deletes(${li.reimburseId })">删除</a></td>
			</tr>
		</c:forEach>
	</table>
	<jsp:include page="/WEB-INF/view/pages.jsp"></jsp:include>
	<script type="text/javascript">
		$(function(){
			$.post(
				"${pageContext.request.contextPath }/xiala",
				{},
				function(msg){
					for (var i = 0; i < msg.length; i++) {
						if (depid==msg[i].id) {
							$("#dep").append('<option value="'+msg[i].id+'" selected="selected">'+msg[i].name+'</option>');
						}else {
							$("#dep").append('<option value="'+msg[i].id+'">'+msg[i].name+'</option>');
						}
					}
				},
				"json"
			)
		})
		function goPage(pageNum){
			$("#ym").val(pageNum);
			$("#fm").submit();
		}
		function deletes(id){
			if (confirm("确定要删除吗?")) {
				location="${pageContext.request.contextPath }/delete?id="+id;
			}else {
				alert("已经取消删除");
			}
		}
	</script>
</body>
</html>